//
//  SunThirdVC.m
//  Xspcf
//
//  Created by sunshine on 16/10/11.
//  Copyright © 2016年 小小算盘. All rights reserved.
//

#import "SunThirdVC.h"
#import "SunMyOrderVC.h"
#import "SunMyCardsVC.h"
#import "SunBankManagerVC.h"
#import "SunLoginVC.h"
#import "SunOptionVC.h"
#import "SunInputVC.h"
#import "SunGetMoneyVC.h"
#import "SunMyMsgVC.h"
#import "SunWebVC.h"
#import "SunDelegateWebVC.h"
/////////////////
#import "MyLuckyDrawController.h"
/////////////////
#import "OpenBindSuccessViewController.h"


#undef Y
#define Y(y) BY(y)
@interface SunThirdVC ()
{
    UILabel *_userPhone;
    UILabel *_totalMoney;//总资产
    UILabel *_leaveMoney;//可用余额
    UILabel *_profitMoney;//累计收益
    Sun *_sun;
    UIView *_loginView;
    UIButton *_eye;
    BOOL _showBind;
}
@end

@implementation SunThirdVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = BACKGROUND;
    [self initData];
    [self creatUI];
    // Do any additional setup after loading the view.
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
    if (![[NSUserDefaults standardUserDefaults] boolForKey:KLOGIN]) {
        [self showLogin];
    }else {
        if (_loginView) {
            [_sun hideAll];
        }
        [self requestToUser];
    }
    if ([[NSUserDefaults standardUserDefaults]boolForKey:@"third_hide"]) {
        _eye.selected = NO;
    }else {
        _eye.selected = YES;
    }
    [self showDetails:_eye];
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:NO];
}

- (void)showLogin{
    if (!_loginView) {
        _loginView = [[UIView alloc]init];
        UIView *view = [[UIView alloc]init];
        [_loginView addSubview:view];
        UIImageView *imgV1 = [[UIImageView alloc]init];
        [view addSubview:imgV1];
        [imgV1 setFrame:CGRectMake(-3, SCREENHEIGHT - 280, SCREENWIDTH + 26, 250)];
        imgV1.image = [UIImage imageNamed:@"hb_BG"];
        imgV1.userInteractionEnabled = YES;
        UIButton *btn = [[UIButton alloc]init];
        [imgV1 addSubview:btn];
        [btn lt_XcenterTo:nil save:YES];
        [btn lt_setTop:90 to:nil save:YES];
        [btn lt_setSize:CGSizeMake(286, 44) save:YES];
        [btn setBackgroundImage:[UIImage imageNamed:@"sign_button"] forState:UIControlStateNormal];
        [btn setTitle:@"登录" forState:UIControlStateNormal];
        [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [btn.titleLabel setFont:[UIFont systemFontOfSize:18]];
        [btn addTarget:self action:@selector(gotoLogin) forControlEvents:UIControlEventTouchUpInside];
        
        UIButton *btn2 = [[UIButton alloc]init];
        [imgV1 addSubview:btn2];
        [btn2 lt_XcenterTo:nil save:YES];
        [btn2 lt_setTop:20 to:btn save:YES];
        [btn2 lt_setSize:CGSizeMake(286, 44) save:YES];
        [btn2 setBackgroundImage:[UIImage imageNamed:@"register_button"] forState:UIControlStateNormal];
        [btn2 setTitle:@"注册" forState:UIControlStateNormal];
        [btn2 setTitleColor:[UIColor colorWithHexString:@"F96D60"] forState:UIControlStateNormal];
        [btn2.titleLabel setFont:[UIFont systemFontOfSize:18]];
        [btn2 addTarget:self action:@selector(gotoLogin) forControlEvents:UIControlEventTouchUpInside];
        
        UILabel *label = [[UILabel alloc]init];
        [imgV1 addSubview:label];
        [label lt_layoutView:label side:SunCenterX to:nil toSide:SunCenterX withSize:1 offset:X(5) save:YES];
        [label lt_setTop:Y(10) to:btn2 save:YES];
        label.textColor = [UIColor colorWithHexString:@"000000"];
        label.font = [UIFont systemFontOfSize:13];
        label.text = [Sun getUser:SAFETEXT];
        UIImageView *imgV2 = [[UIImageView alloc]init];
        [imgV1 addSubview:imgV2];
        [imgV2 lt_YcenterTo:label save:YES];
        [imgV2 lt_setRight:X(3) to:label save:YES];
        imgV2.image = [UIImage imageNamed:@"safe_icon"];
        [view lt_topEqual:imgV1 save:YES];
        [view lt_bottomEqual:imgV1 save:YES];
        [view lt_leftEqual:imgV1 save:YES];
        [view lt_rightEqual:imgV1 save:YES];
        [view lt_XYcenterTo:nil save:YES];
    }
    [_sun show:_loginView to:self shouldReturn:NO];
    [_loginView lt_All:SunEdgesMake(0, 0, 0, 0) save:YES];
}

- (void)initData{
    _sun = [[Sun alloc]init];
}

- (void)creatUI{
    // 上方区域
    UIImageView *headView = [[UIImageView alloc]init];
    [self.view addSubview:headView];
    [headView lt_Top:SunEdgesMake(0, 0, 0, 318) to:nil save:YES];
    headView.image = [Sun imageWithColorFrom:[HXColor colorWithHexString:@"FFFFFF"] To:[HXColor colorWithHexString:@"FFFFFF"] Frame:CGRectMake(0, 0, SCREENWIDTH, 318) Direction:SunDirectionBottom];
    headView.userInteractionEnabled = YES;
    // logo
    UIImageView *logoImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"third_head"]];
    [headView addSubview:logoImage];
    [logoImage lt_XYcenterTo:nil save:YES];
    [logoImage lt_setLeft:X(17) to:nil save:YES];
    [logoImage lt_setTop:35 to:nil save:YES];
    [logoImage lt_setSize:CGSizeMake(43, 43) save:YES];
    // 手机号
    _userPhone = [[UILabel alloc]init];
    [headView addSubview:_userPhone];
    [_userPhone lt_YcenterTo:logoImage save:YES];
    [_userPhone lt_setHeight:Y(12) save:YES];
    [_userPhone lt_setLeft:10 to:logoImage save:YES];
    _userPhone.textColor = [UIColor colorWithHexString:@"5F5F5F"];
    _userPhone.font = [UIFont fontWithName:@"PingFangSC-Regular" size:14];
    _userPhone.text = @"***********";
    // 设置按钮（安全中心）
    UIButton *setButton = [[UIButton alloc]init];
    [headView addSubview:setButton];
    [setButton setImage:[UIImage imageNamed:@"third_set"] forState:UIControlStateNormal];
    [setButton lt_setSize:CGSizeMake(50, 50) save:YES];
    [setButton lt_YcenterTo:logoImage save:YES];
    [setButton lt_setRight:X(7) to:nil save:YES];
    [setButton addTarget:self action:@selector(optionAction) forControlEvents:UIControlEventTouchUpInside];
    // 总资产文字
    UILabel *label1 = [[UILabel alloc]init];
    [headView addSubview:label1];
    [label1 lt_setTop:106 to:nil save:YES];
    [label1 lt_setLeft:X(130) to:nil save:YES];
    label1.textColor = [UIColor colorWithHexString:@"ACACAC"];
    label1.font = [UIFont fontWithName:@"PingFangSC-Regular" size:12];
    label1.text = @"账户总资产(元)";
    // 隐藏/显示
    _eye = [[UIButton alloc]init];
    [headView addSubview:_eye];
    [_eye lt_setLeft:4 to:label1 save:YES];
    [_eye lt_YcenterTo:label1 save:YES];
    [_eye lt_setSize:CGSizeMake(40, 30) save:YES];
    [_eye setImage:[UIImage imageNamed:@"third_eye"] forState:UIControlStateNormal];
    [_eye setImage:[UIImage imageNamed:@"third_uneye"] forState:UIControlStateSelected];
    [_eye addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside];
    // 总资产数字
    _totalMoney = [[UILabel alloc]init];
    [headView addSubview:_totalMoney];
    [_totalMoney lt_XcenterTo:nil save:YES];
    [_totalMoney lt_setTop:10 to:label1 save:YES];
    [_totalMoney lt_setHeight:Y(36) save:YES];
    _totalMoney.textColor = [UIColor colorWithHexString:@"FF715F"];
    _totalMoney.font = [UIFont fontWithName:@"DINCondensed-Bold" size:36];
    _totalMoney.text = @"0.00";
    _totalMoney.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapToTotal)];
    [_totalMoney addGestureRecognizer:tap1];
    // 可用余额
    UIImageView *leftBg = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"third_button"]];
    [headView addSubview:leftBg];
    [leftBg lt_Bottom:SunEdgesMake(0, 63, SCREENWIDTH / 2.0 + 1, 60) to:nil save:YES];
    _leaveMoney = [[UILabel alloc]init];
    [leftBg addSubview:_leaveMoney];
    [_leaveMoney lt_XcenterTo:nil save:YES];
    [_leaveMoney lt_setHeight:Y(20) save:YES];
    [_leaveMoney lt_setTop:Y(12) to:nil save:YES];
    _leaveMoney.textColor = [UIColor colorWithHexString:@"DFBD7A"];
    _leaveMoney.font = [UIFont fontWithName:@"DINCondensed-Bold" size:20];
    _leaveMoney.text = @"0.00";
    leftBg.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapToLeave)];
    [leftBg addGestureRecognizer:tap2];
    UILabel *label2 = [[UILabel alloc]init];
    [leftBg addSubview:label2];
    [label2 lt_XcenterTo:nil save:YES];
    [label2 lt_setHeight:Y(14) save:YES];
    [label2 lt_setTop:Y(4) to:_leaveMoney save:YES];
    label2.textColor = [UIColor colorWithHexString:@"C4C4C4"];
    label2.font = [UIFont fontWithName:@"PingFangSC-Regular" size:12];
    label2.text = @"可用余额(元)";
    // 累计收益
    UIImageView *rightBg = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"third_button"]];
    [headView addSubview:rightBg];
    [rightBg lt_Bottom:SunEdgesMake(SCREENWIDTH / 2.0 + 1, 63, 0, 60) to:nil save:YES];
    _profitMoney = [[UILabel alloc]init];
    [rightBg addSubview:_profitMoney];
    [_profitMoney lt_XcenterTo:nil save:YES];
    [_profitMoney lt_setHeight:Y(20) save:YES];
    [_profitMoney lt_setTop:Y(12) to:nil save:YES];
    _profitMoney.textColor = [UIColor colorWithHexString:@"DFBD7A"];
    _profitMoney.font = [UIFont fontWithName:@"DINCondensed-Bold" size:20];
    _profitMoney.text = @"0.00";
    rightBg.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapToProfit)];
    [rightBg addGestureRecognizer:tap3];
    UILabel *label3 = [[UILabel alloc]init];
    [rightBg addSubview:label3];
    [label3 lt_XcenterTo:nil save:YES];
    [label3 lt_setHeight:Y(14) save:YES];
    [label3 lt_setTop:Y(4) to:_profitMoney save:YES];
    label3.textColor = [UIColor colorWithHexString:@"C4C4C4"];
    label3.font = [UIFont fontWithName:@"PingFangSC-Regular" size:12];
    label3.text = @"累计收益(元)";
    
    UILabel *lineX = [[UILabel alloc]init];
    [headView addSubview:lineX];
    [lineX setFrame:CGRectMake(X(14), 275, SCREENWIDTH - X(28), 1)];
    [lineX setBackgroundColor:[UIColor colorWithHexString:@"E1E1E1"]];
    
    UIImageView *lineY = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"second_line"]];
    [headView addSubview:lineY];
    [lineY lt_XcenterTo:nil save:YES];
    [lineY lt_setTop:6 to:lineX save:YES];
    // 充值
    UIButton *inputButton = [[UIButton alloc]init];
    [headView addSubview:inputButton];
    [inputButton lt_setSize:CGSizeMake(SCREENWIDTH/2-2, 40) save:YES];
    [inputButton lt_setTop:1 to:lineX save:YES];
    [inputButton lt_setLeft:1 to:nil save:YES];
    [inputButton setTitle:@"充值" forState:UIControlStateNormal];
    [inputButton setTitleColor:[UIColor colorWithHexString:@"FA7060"] forState:UIControlStateNormal];
    inputButton.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:16];
    [inputButton addTarget:self action:@selector(inputAction) forControlEvents:UIControlEventTouchUpInside];
    // 提现
    UIButton *getMoneyButton = [[UIButton alloc]init];
    [headView addSubview:getMoneyButton];
    [getMoneyButton lt_setSize:CGSizeMake(SCREENWIDTH/2-2, 40) save:YES];
    [getMoneyButton lt_setTop:1 to:lineX save:YES];
    [getMoneyButton lt_setRight:1 to:nil save:YES];
    [getMoneyButton setTitle:@"提现" forState:UIControlStateNormal];
    [getMoneyButton setTitleColor:[UIColor colorWithHexString:@"B6B6B6"] forState:UIControlStateNormal];
    getMoneyButton.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:16];
    [getMoneyButton addTarget:self action:@selector(getMoneyAction) forControlEvents:UIControlEventTouchUpInside];
    // 下方四个按钮
    UIView *center = [[UIView alloc]init];
    [self.view addSubview:center];
    [center lt_Top:SunEdgesMake(4, 0, 0, 100) to:headView save:YES];
    center.backgroundColor = WHITE;
    
    UIButton *orderBtn = [self btnWithImg:[UIImage imageNamed:@"third_order"] Title:@"我的投资"];
    [center addSubview:orderBtn];
    [orderBtn addTarget:self action:@selector(orderAction) forControlEvents:UIControlEventTouchUpInside];
    [orderBtn lt_setTop:0 to:nil Bottom:0 to:nil save:YES];
    
    UIButton *cardBtn = [self btnWithImg:[UIImage imageNamed:@"third_card"] Title:@"我的优惠券"];
    [center addSubview:cardBtn];
    [cardBtn addTarget:self action:@selector(cardAction) forControlEvents:UIControlEventTouchUpInside];
    [cardBtn lt_setTop:0 to:nil Bottom:0 to:nil save:YES];
    
    UIButton *invBtn = [self btnWithImg:[UIImage imageNamed:@"third_inv"] Title:@"邀请好友奖励"];
    [center addSubview:invBtn];
    [invBtn addTarget:self action:@selector(inviteAction) forControlEvents:UIControlEventTouchUpInside];
    [invBtn lt_setTop:0 to:nil Bottom:0 to:nil save:YES];
    
    UIButton *bankBtn = [self btnWithImg:[UIImage imageNamed:@"third_bank"] Title:@"银行卡管理"];
    [center addSubview:bankBtn];
    [bankBtn addTarget:self action:@selector(bankAction) forControlEvents:UIControlEventTouchUpInside];
    [bankBtn lt_setTop:0 to:nil Bottom:0 to:nil save:YES];
    
    NSArray *cons = [NSLayoutConstraint constraintsWithVisualFormat:@"|-0-[v1]-0-[v2(==v1)]-0-[v3(==v1)]-0-[v4(==v1)]-0-|" options:0 metrics:nil views:@{@"v1":orderBtn,@"v2":cardBtn,@"v3":invBtn,@"v4":bankBtn}];
    [center addConstraints:cons];
    
}
#pragma mark- 设置
- (void)optionAction{
    SunOptionVC *vc = [[SunOptionVC alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}
#pragma mark- 充值
- (void)inputAction {
    NSDictionary *dic = [Sun getUser:USER];
    if ([[dic objectForKey:@"isActivate"] intValue] == 1) {
        [SunSupport shouldAlert:self code:UserActivate];
    }else if ([[dic objectForKey:@"status"] intValue] == 3) {
        SunInputVC *vc = [[SunInputVC alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }else {
        [SunSupport shouldAlert:self code:UserOpen];
    }
}
#pragma mark- 提现
- (void)getMoneyAction {
    NSDictionary *dic = [Sun getUser:USER];
    if ([[dic objectForKey:@"isActivate"] intValue] == 1) {
        [SunSupport shouldAlert:self code:UserActivate];
    }else
        if ([[dic objectForKey:@"status"] intValue] == 3) {
            SunGetMoneyVC *vc = [[SunGetMoneyVC alloc]init];
            [self.navigationController pushViewController:vc animated:YES];
        }else {
            [SunSupport shouldAlert:self code:UserOpen];
        }
}
#pragma mark- 投资、卡券、邀请、银行卡
- (void)orderAction {
    SunMyOrderVC *vc = [[SunMyOrderVC alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)cardAction {
    SunMyCardsVC *vc = [[SunMyCardsVC alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)inviteAction {
    NSDictionary *dic = [Sun getUser:USER];
    MyLuckyDrawController *vc = [[MyLuckyDrawController alloc]init];
    if ([dic objectForKey:@"status"]) {
        vc.Mystatus = @"1";
    }else {
        vc.Mystatus = @"0";
    }
    vc.MyName = [dic objectForKey:@"name"];
    vc.MyNumber = [dic objectForKey:@"phone"];
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)bankAction {
    NSDictionary *dic = [Sun getUser:USER];
    if ([[dic objectForKey:@"isActivate"] intValue] == 1) {
        [SunSupport shouldAlert:self code:UserActivate];
    }else if ([[dic objectForKey:@"status"] intValue] == 3) {
        SunBankManagerVC *vc = [[SunBankManagerVC alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }else {
        [SunSupport shouldAlert:self code:UserOpen];
    }
}
#pragma mark- btnWithImg
- (UIButton *)btnWithImg:(UIImage *)img Title:(NSString *)title{
    UIButton *btn = [[UIButton alloc]init];
    [btn setImage:img forState:UIControlStateNormal];
    [btn setTitle:title forState:UIControlStateNormal];
    [btn setTitleColor:BLACK forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateHighlighted];
    btn.titleLabel.font = [UIFont systemFontOfSize:12];
    [btn verticalImageAndTitle:0];
    return btn;
}

- (NSString *)get:(NSString *)key from:(NSDictionary *)dic{
    if ([[dic objectForKey:key]isKindOfClass:[NSNumber class]]) {
        return [NSString stringWithFormat:@"%@",[dic objectForKey:key]];
    }else {
        return [dic objectForKey:key];
    }
}

- (void)updateViews{
    NSDictionary *dic = [Sun getUser:USER];
    _totalMoney.text = [NSString stringWithFormat:@"%.2f",[[dic objectForKey:@"totalMoney"] floatValue]];
    _leaveMoney.text = [NSString stringWithFormat:@"%.2f",[[dic objectForKey:@"balanceMoney"] floatValue]];
    _profitMoney.text = [NSString stringWithFormat:@"%.2f",[[dic objectForKey:@"totalProfit"] floatValue]];

    _userPhone.text = [Sun hidePhone:[dic objectForKey:@"phone"]];
}

- (void)tapToTotal{
    NSDictionary *dic = [Sun getUser:USER];
    if ([[dic objectForKey:@"isActivate"] intValue] == 1) {
        [SunSupport shouldAlert:self code:UserActivate];
    }else if ([[dic objectForKey:@"status"] intValue] == 3) {
        SunWebVC *vc = [[SunWebVC alloc]init];
        NSString *str = @"CZfSDQzsuDayjfzE";
        NSString *str1 =@"12345678";
        NSString *token_id=[Utility encryptStr:[NSString stringWithFormat:@"%@",[Sun getUser:ACCESSID]]  Key:str1 IV:nil];
        NSString *md5Str=[Utility md5:[NSString stringWithFormat:@"source=ios&token_id=%@&%@",token_id,str]];
        vc.urlStr = [NSString stringWithFormat:@"%@/account/total?source=ios&token_id=%@&sign=%@",KWAP,token_id,md5Str];
        [self.navigationController pushViewController:vc animated:YES];
    }else {
        [SunSupport shouldAlert:self code:UserOpen];
    }
    
    
}
- (void)tapToLeave{
    NSDictionary *dic = [Sun getUser:USER];
    if ([[dic objectForKey:@"isActivate"] intValue] == 1) {
        [SunSupport shouldAlert:self code:UserActivate];
    }else if ([[dic objectForKey:@"status"] intValue] == 3) {
        SunWebVC *vc = [[SunWebVC alloc]init];
        vc.title = @"可用余额";
        NSString *str = @"CZfSDQzsuDayjfzE";
        NSString *str1 =@"12345678";
        NSString *token_id=[Utility encryptStr:[NSString stringWithFormat:@"%@",[Sun getUser:ACCESSID]]  Key:str1 IV:nil];
        NSString *md5Str=[Utility md5:[NSString stringWithFormat:@"source=ios&token_id=%@&%@",token_id,str]];
        vc.urlStr = [NSString stringWithFormat:@"%@/account/use_money?source=ios&token_id=%@&sign=%@",KWAP,token_id,md5Str];
        [self.navigationController pushViewController:vc animated:YES];
    }else {
        [SunSupport shouldAlert:self code:UserOpen];
    }
    
}

- (void)tapToProfit{
    NSDictionary *dic = [Sun getUser:USER];
    if ([[dic objectForKey:@"isActivate"] intValue] == 1) {
        [SunSupport shouldAlert:self code:UserActivate];
    }else if ([[dic objectForKey:@"status"] intValue] == 3) {
        SunWebVC *vc = [[SunWebVC alloc]init];
        NSString *str = @"CZfSDQzsuDayjfzE";
        NSString *str1 =@"12345678";
        NSString *token_id=[Utility encryptStr:[NSString stringWithFormat:@"%@",[Sun getUser:ACCESSID]]  Key:str1 IV:nil];
        NSString *md5Str=[Utility md5:[NSString stringWithFormat:@"source=ios&token_id=%@&%@",token_id,str]];
        vc.urlStr = [NSString stringWithFormat:@"%@/account/total_interest?source=ios&token_id=%@&sign=%@",KWAP,token_id,md5Str];
        [self.navigationController pushViewController:vc animated:YES];
    }else {
        [SunSupport shouldAlert:self code:UserOpen];
    }
    
}

- (void)gotoLogin{
    SunLoginVC *vc = [[SunLoginVC alloc]init];
    vc.isWeb = NO;
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)showDetails:(UIButton *)btn{
    if (btn.isSelected) {
        btn.selected = NO;
        [self updateViews];
        [Sun setUser:@"0" forKey:@"third_hide"];
    }else {
        btn.selected = YES;
        _totalMoney.text = @"***";
        _leaveMoney.text = @"***";
        _profitMoney.text = @"***";
        _userPhone.text = @"***";
        [Sun setUser:@"1" forKey:@"third_hide"];
    }
}
#pragma mark request
- (void)requestToUser{
    NSString *url = [NSString stringWithFormat:@"%@%@",KURL,API_USERINFO];
    [HttpRequest postURL:url withParam:nil success:^(id requestDic, NSString *msg) {
        [[Sun shareSun]hideActivity];
        if ([[Sun getUser:@"third_hide"] intValue] == 1) {
            _eye.selected = NO;
        }else {
            _eye.selected = YES;
        }
        [Sun setUser:requestDic forKey:USER];
        if ([[requestDic objectForKey:@"isActivate"] intValue] == 1) {
            [SunSupport shouldAlert:self code:UserActivate];
        }else if (!_showBind && [[requestDic objectForKey:@"status"] intValue] != 3) {
            _showBind = YES;
            [SunSupport shouldAlert:self code:UserOpen];
        }

        [self showDetails:_eye];
    } failure:^(NSString *errorInfo, int code) {
        [[Sun shareSun]showMsg:errorInfo];
        [[Sun shareSun]hideActivity];
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
